<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            margin: 100px;
            width: 460px;
        }

        .box .btn {
            height: 40px;
            margin-bottom: 5px;
        }

        .box .btn input {
            float: left;
            width: 100px;
            text-align: center;
            height: 40px;
            margin-right: 20px;
            border: 1px solid #334455;
        }

        .box .btn input:nth-child(4) {
            margin-right: 0px;
        }

        .box .con {
            width: 460px;
            height: 400px;
            border: 1px solid #ccc;
            box-sizing: border-box;
            display: none;
        }

        .box .btn .active {
            background: orange;
        }
    </style>
</head>

<body>
    <!-- ## 3.实现选项卡(思考) -->
    <div class="box">
        <div class="btn">
            <input type="button" class="btnlist active" value="体育">
            <input type="button" class="btnlist" value="娱乐">
            <input type="button" class="btnlist" value="新闻">
            <input type="button" class="btnlist" value="教育">
        </div>

        <div class="con" style="display: block;">体育</div>
        <div class="con">娱乐</div>
        <div class="con">新闻</div>
        <div class="con">教育</div>

    </div>
    <script>
        var btn = document.getElementsByTagName('input');
        var con = document.getElementsByClassName('con');

        for (var i = 0; i < btn.length; i++) {
            btn[i].idx=i;
            btn[i].onclick = function () {      
                for (var j = 0; j < btn.length; j++) {
                    btn[j].className= 'btnlist';
                    con[j].style.display='none'
                }
                this.className = 'btnList active';
                con[this.idx].style.display='block';
            }
        }
    </script>
</body>

</html>